package com.vivz.guess.what;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.LinearLayout;

import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;

public class HomeActivity extends Activity {

	// //////////////////
	// Screen Elements
	// //////////////////

	private LinearLayout adSectionLayout;
	private AdView adView;

	@Override
	protected void onCreate(final Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_home);

		// Initialize screen elements
		adSectionLayout = (LinearLayout) findViewById(R.id.ad_section_home);
		loadAdView();

	}

	private void loadAdView() {

		// Create the adView
		adView = new AdView(this, AdSize.BANNER, getString(R.string.admob_id));

		// Add the adView to it
		adSectionLayout.addView(adView);

		// Initiate a generic request to load it with an ad
		adView.loadAd(new AdRequest());

	}

	@Override
	public boolean onCreateOptionsMenu(final Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.home, menu);
		return true;
	}

	/**
	 * Called when the user hits the Guess button.
	 * 
	 * @param view
	 */
	public void launchNewGame(final View view) {
		final Intent newGameIntent = new Intent(HomeActivity.this, MainActivity.class);
		startActivity(newGameIntent);
	}

	/**
	 * Called when the user hits the Guess button.
	 * 
	 * @param view
	 */
	public void launchSettings(final View view) {
		final Intent settingsIntent = new Intent(HomeActivity.this, SetPreferenceActivity.class);
		startActivity(settingsIntent);
	}

	/**
	 * Called when the user hits the Guess button.
	 * 
	 * @param view
	 */
	public void launchAbout(final View view) {
		final Intent aboutIntent = new Intent(HomeActivity.this, AboutActivity.class);
		startActivity(aboutIntent);
	}

}
